package edu.ucsd.ccdb.tagPopup.summaryPane;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

import edu.ucsd.ccdb.tagPopup.dataType.NIFOnthologyType;
import edu.ucsd.ccdb.tagPopup.dataType.OthoTagElementDisplay;
import edu.ucsd.irods.IRODSFileString;
import edu.ucsd.irods.SQLDBQuery;

public class OnthoTagSummaryPane extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public OnthoTagSummaryPane( String username, JPanel source, Integer MPID, IRODSFileString file, String screenName ) {
		List<NIFOnthologyType> data = new ArrayList<NIFOnthologyType>();
		try {
			data = SQLDBQuery.getDisplayOthoTag(MPID, file.getAbsolutePath() , screenName);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		
		add (new JLabel("Othology Tags: ") );
		
		for (NIFOnthologyType element: data ) {
			add ( new OthoTagElementDisplay( username, source, MPID, file, screenName, element) );
		}
	}
	 
	//TODO this need to think through . Refactor and redesign :D
	public static List<String> getBriefSummary (Integer MPID, IRODSFileString file, String screenName ) {
		List<NIFOnthologyType> data = new ArrayList<NIFOnthologyType>();
		
		try {
			data = SQLDBQuery.getDisplayOthoTag(MPID, file.getAbsolutePath() , screenName);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		List<String > result = new ArrayList <String>();
		
		for (NIFOnthologyType element: data) {
			result.add( element.getLabel() );
		}
		
		return result;
	}
}
